#pragma once

//@author A0096950U
#include <vector>
#include <algorithm>
#include <assert.h>
#include "Task.h"
#include "Logger.h"

using namespace std;

class Display {
protected:
	vector<Task> tasksDisplayed;
	Logger& logger;

	// Comparator method for std::sort
	// Compare based on startTime of Tasks
	static bool sortTaskTime(const Task& task1, const Task& task2);

	// Comparator method for std::sort
	// Compare based on date of Tasks
	static bool sortTaskDate(const Task& task1, const Task& task2);

public:
	Display(void);

	// Pre: nil
	// Post: returns the size of display
	int size() const;

	// Pre: Task object to be added has been constructed
	// Post: Task object added to display as the last element
	void push_back(const Task&);

	// Pre: userIndex is valid, any userIndex exception to be thrown by caller
	// Post: Task at position userIndex is removed from display
	void remove(int userIndex);

	// Pre:	nil
	// Post: Task with the corresponding taskID is removed from display
	//		 If Task is not in display or ID is invalid, do nothing
	void remove(string taskID);

	// Pre: nil
	// Post: display is emptied
	void clear();

	// Pre: newTask is already constructed
	// Post: Task with the same taskID as newTask in display is updated
	//		 If Task is not in display, do nothing
	void modify(Task& newTask);

	// Pre: userIndex is valid, any userIndex exception to be thrown by caller
	// Post: returns Task object of the specified userIndex
	Task getTask(int userIndex) const;

	// Pre: Task with given taskID exists in display
	// Post: returns the Task with the specified taskID
	Task getTask(string taskID) const;

	// Pre: newDisplay is already constructed
	// Post: display is updated to newDisplay
	void setTasksDisplayed(vector<Task>& newDisplay);

	// Pre: nil
	// Post: returns a copy of Tasks displayed
	vector<Task> getTasksDisplayed() const;

	// Pre: nil
	// Post: display is sorted based on time
	void sortByTime();

	// Pre: nil
	// Post: display is sorted based on date
	void sortByDate();

	void setStatus(int userIndex, TaskStatus newStatus);
};

